package com.wzh.sending.service;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;

import com.wzh.sending.FindUserActivity;

/**
 * Created by Hu on 2016/8/30.
 */
public class StartBroadcast extends BroadcastReceiver {
    SharedPreferences preferences;
    @Override
    public void onReceive(Context context, Intent intent) {
        //后边的XXX.class就是要启动的服务
        Log.e("TAG", "开机自动服务自动启动.....");
        preferences = context.getSharedPreferences("loc", Context.MODE_PRIVATE);
        if (preferences.contains("issend")) {
            if (preferences.getBoolean("issend", false)) {
                Intent service = new Intent(context,MyService.class);
                context.startService(service);
            }
        } else {
            Intent service = new Intent(context,MyService.class);
            context.startService(service);
        }

    }
}
